package com.huichenghe.xinlvsh01.zhy.utils;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.WindowManager;

import com.huichenghe.xinlvsh01.MainActivity;
import com.huichenghe.xinlvsh01.R;
import com.huichenghe.xinlvsh01.Utils.LocalDataSaveTool;
import com.huichenghe.xinlvsh01.Utils.MyConfingInfo;
import com.huichenghe.xinlvsh01.slide.LoginActivity;
import com.huichenghe.xinlvsh01.slide.Sub_login;


/**
 * 欢迎页面
 */
public class WelcomeActivity extends AppCompatActivity
{
    private String account;
    private String password;

    private CoordinatorLayout mCoordinatorLayout;
    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        /** 设置隐藏底部导航键 */
        mCoordinatorLayout = (CoordinatorLayout)findViewById(R.id.welcom_layout);
        mCoordinatorLayout.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

        /** 设置状态栏透明*/
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

        account = LocalDataSaveTool.getInstance(WelcomeActivity.this).readSp(MyConfingInfo.USER_ACCOUNT);
        password = LocalDataSaveTool.getInstance(WelcomeActivity.this).readSp(MyConfingInfo.USER_PASSWORD);


    }

    @Override
    protected void onResume() {
        super.onResume();
        if(!account.isEmpty() && !password.isEmpty())
        {
            startActy(WelcomeActivity.this, MainActivity.class);
        }
        else
        {
            startActy(WelcomeActivity.this, nextToLoginActivity.class);
        }




//        // 两秒钟后进入下一级页面
//        mHandler.postDelayed(new Runnable()
//        {
//            @Override
//            public void run()
//            {
//
//
//
//
//
//            }
//        }, 1000);
    }


    private void startActy(Context mContext, Class<?> clazz)
    {
        Intent mIntent = new Intent(mContext, clazz);
        mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(mIntent);
        WelcomeActivity.this.finish();
    }

}
